package com.wrx.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wrx.server.pojo.Bar;
import com.wrx.server.pojo.ThemePost;
import com.wrx.server.pojo.ThemePostModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wrx
 * @since 2021-04-20
 */
@Repository
public interface ThemePostMapper extends BaseMapper<ThemePost> {

    /**
     * 写入一条新主题帖
     * @param bar_id
     * @param user_id
     * @param theme_post_title
     * @param theme_post_info
     */
    public void insertThemePost(Integer bar_id,Integer user_id,String theme_post_title,String theme_post_info);

    /**
     * 输出对应贴吧id的所有主题帖
     * @param bar_id
     * @return
     */
    public List<ThemePostModel> selLastTimeAllThemePost(@Param("barid")int bar_id, @Param("sortType")String sortType);

    public List<ThemePostModel> selPutTimeAllThemePost(@Param("barid")int bar_id, @Param("sortType")String sortType);
    /**
     * 主题帖回帖数+1
     * @param theme_post_id
     * @return
     */
    public int addReplyThemePostNumber(int theme_post_id);

    /**
     * 主题帖回帖数-1
     * @param theme_post_id
     * @return
     */
    public int delReplyThemePostNumber(int theme_post_id);

    /**
     * 查询一条主题帖数据
     * @param theme_post_id
     * @return
     */
    public List<ThemePost> selOneThemePost(int theme_post_id);

    /**
     * 查询一条主题帖以及用户名
     * @param theme_post_id
     * @return
     */
    public List<ThemePostModel> selOneThemePostAndNetNameByThemePostId(int theme_post_id);

    /**
     * 查询主题帖的回复数量，根据主题帖id
     * @param theme_post_id
     * @return
     */
    public int selThemePostReplyNumber(int theme_post_id);

    /**
     * 查询主题帖id，根据主题帖id
     * @param theme_post_id
     * @return
     */
    public Integer selThePostIdByThemePostId(int theme_post_id);
    /**
     * 查询bar_id，根据主题帖id
     * @param theme_post_id
     * @return
     */
    public int selBarIdByThemePost(int theme_post_id);

    /**
     * 查询主题帖帖主，根据主题帖id
     * @param theme_post_id
     * @return
     */
    public int selThemePostUserId(int theme_post_id);

}
